﻿Public Class frmNhapHangThanhCong

    Private Sub frmNhapHangThanhCong_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim MaPhieu As Integer = Me.Tag
        lbMaPhieu.Text = MaPhieu.ToString()
    End Sub

    Private Sub btnInHoaDon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInHoaDon.Click
        Dim frm As frmPhieuNhapHang = New frmPhieuNhapHang()
        Dim report As rpPhieuNhapHang = New rpPhieuNhapHang()
        'Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        'Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

        'For Each tbCurrent In report.Database.Tables
        '    tliCurrent = tbCurrent.LogOnInfo
        '    With tliCurrent.ConnectionInfo
        '        .ServerName = "../../Database/QLTapHoa.mdb"
        '        .UserID = ""
        '        .Password = ""
        '        .DatabaseName = "QLTapHoa"
        '    End With
        '    tbCurrent.ApplyLogOnInfo(tliCurrent)
        'Next tbCurrent
        Dim logOnInfoTable As CrystalDecisions.Shared.TableLogOnInfo = New CrystalDecisions.Shared.TableLogOnInfo()
        Dim currentTable As CrystalDecisions.CrystalReports.Engine.Table
        For Each currentTable In report.Database.Tables
            Dim test As String = Application.StartupPath
            Dim abc As String
            abc = Replace(test, "bin\Debug", "Database\QLTapHoa.mdb")
            logOnInfoTable.ConnectionInfo.ServerName = abc

            currentTable.ApplyLogOnInfo(logOnInfoTable)
        Next
        report.SetParameterValue("MaNhapHang", lbMaPhieu.Text)
        frm.KhoiTaoReport(report)
        frm.Show()


    End Sub

End Class